Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.MedicallicensesForm = Ext.extend(Divo.Base.EditForm, {
      fields : new Ext.util.MixedCollection(),
      dataRecordMeta : Ext.data.Record.create([{
            name : "_p_record_status",
            type : "string"
          }, {
            name : "id",
            type : "float"
          }, {
            name : "supplierId",
            type : "float"
          }, {
            name : "supplier",
            type : "string"
          }, {
            name : "produceId",
            type : "float"
          }, {
            name : "produce",
            type : "string"
          }, {
            name : "shortName",
            type : "string"
          }, {
            name : "registerNo",
            type : "string"
          }, {
            name : "highValueAllName",
            type : "string"
          }, {
            name : "highValueItemName",
            type : "string"
          }, {
            name : "checkDate",
            type : "string"
          }, {
            name : "endDate",
            type : "string"
          }]),
      initComponent : function() {
        var me = this;
        var tn = 1;

        this.fields.add("_p_record_status", new Ext.form.Hidden({
                  name : "_p_record_status"
                }));
        this.fields.add("id", new Ext.form.Hidden({
                  name : "id",
                  dataIndex : "id",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("supplierId", new Ext.form.Hidden({
                  name : "supplierId",
                  dataIndex : "supplierId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("produceId", new Ext.form.Hidden({
                  name : "produceId",
                  dataIndex : "produceId",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("shortName", new app.base.TextField({
                  name : "shortName",
                  dataIndex : "shortName",
                  fieldLabel : "厂家简称",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("registerNo", new app.base.TextField({
                  name : "registerNo",
                  dataIndex : "registerNo",
                  fieldLabel : "医疗器械注册号",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("highValueAllName", new app.base.TextField({
                  name : "highValueAllName",
                  dataIndex : "highValueAllName",
                  fieldLabel : "高值耗材通用名",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("highValueItemName", new app.base.TextField({
                  name : "highValueItemName",
                  dataIndex : "highValueItemName",
                  fieldLabel : "高值耗材商品名",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("checkDate", new app.base.DateField({
                  name : "checkDate",
                  dataIndex : "checkDate",
                  fieldLabel : "审批日期",
                  allowBlank : false,
                  format : 'Y.m.d',
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("endDate", new app.base.DateField({
                  name : "endDate",
                  dataIndex : "endDate",
                  format : 'Y.m.d',
                  fieldLabel : "有效期至",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        var recordDef = Ext.data.Record.create([{
              name : "id",
              type : "float"
            }, {
              name : "name",
              type : "string"
            }]);
        var storeDs = new Ext.data.Store({
              proxy : new Ext.data.HttpProxy({
                    url : 'high_value_material/query_s'
                  }),
              reader : new Ext.data.JsonReader({
                    root : 'rows',
                    totalProperty : 'totalCount',
                    id : 'id'
                  }, recordDef)
            });
        var recordDef2 = Ext.data.Record.create([{
              name : "id",
              type : "float"
            }, {
              name : "name",
              type : "string"
            }]);
        var storeDs2 = new Ext.data.Store({
              proxy : new Ext.data.HttpProxy({
                    url : 'high_value_material/query_s'
                  }),
              reader : new Ext.data.JsonReader({
                    root : 'rows',
                    totalProperty : 'totalCount',
                    id : 'id'
                  }, recordDef2)
            });
        this.fields.add("supplier", new app.base.TextField({
                  name : "supplier",
                  dataIndex : "supplier",
                  fieldLabel : "供应商",
                  allowBlank : false,
                  readOnly : true,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("produce", new app.base.ComboBox({
                  id : 'combo-produce3',
                  name : "produce",
                  dataIndex : "produce",
                  fieldLabel : '选择生产商',
                  store : storeDs,
                  displayField : 'name',
                  valueField : 'id',
                  forceSelection : true,
                  mode : 'remote',
                  triggerAction : 'all',
                  editable : false,
                  allowBlank : false,
                  labelSeparator : ":*",
                  selectOnFocus : true,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true,
                  onSelect : function(record) {
                    var data = record.data;
                    this.setValue(data.name);
                    me.setFieldValue("produceId", data.id);
                    this.onTriggerClick();
                  }
                }));
        Ext.apply(this, {
              items : [this.fields.get("_p_record_status"), {
                layout : "form",
                columnWidth : 1,
                labelAlign : "right",
                labelWidth : 100,
                items : [this.fields.get("id"), this.fields.get("supplierId"),
                    this.fields.get("produceId"), this.fields.get("supplier"),
                    this.fields.get("produce"), this.fields.get("shortName"),
                    this.fields.get("registerNo"),
                    this.fields.get("highValueAllName"),
                    this.fields.get("highValueItemName"),
                    this.fields.get("checkDate"), this.fields.get("endDate")]
              }],
              border : false,
              frame : true,
              firstFocusFieldName : "produce"
            });

        Divo.app.MedicallicensesForm.superclass.initComponent.apply(this,
            arguments);
      }

      ,
      onRender : function() {
        Divo.app.MedicallicensesForm.superclass.onRender.apply(this, arguments);
      },
      newDataRecord : function() {
        return new this.dataRecordMeta({
              _p_record_status : "insert",
              id : "",
              name : "",
              sId : "",
              state : ""
            });
      }

    });
Ext.reg("Divo.app.MedicallicensesForm", Divo.app.MedicallicensesForm);